package sz.szsmk.citizencard.ui.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.AllDistanceViewBinding;
import sz.szsmk.citizencard.util.JumpUtils;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/7/12 15:19
 * description:
 */
public class AllDistanceAdapter extends RecyclerView.Adapter<AllDistanceAdapter.AllDistanceHolder> {

    private Context mContext;

    public AllDistanceAdapter(Context context) {
        mContext = context;
    }

    @Override
    public int getItemViewType(int position) {
        return R.layout.all_distance_view;
    }

    @Override
    public AllDistanceHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return AllDistanceHolder.creat(parent);
    }

    @Override
    public void onBindViewHolder(AllDistanceHolder holder, int position) {
        loadItemData(position, holder.binding);
    }

    private void loadItemData(int position, AllDistanceViewBinding binding) {
        binding.allDistancesRl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                JumpUtils.jump(mContext,"netdetail",0);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 3;
    }

    public static class AllDistanceHolder extends RecyclerView.ViewHolder {

        private AllDistanceViewBinding binding;

        public static AllDistanceHolder creat(ViewGroup parent) {

            AllDistanceViewBinding binding = AllDistanceViewBinding
                    .inflate(LayoutInflater.from(parent.getContext()), parent, false);
            return new AllDistanceHolder(binding);

        }

        public AllDistanceHolder(AllDistanceViewBinding binding) {
            super(binding.getRoot());
            this.binding = binding;

        }
    }
}
